#include"string.h"
string::string(const char* str = "")
	:_size(strlen(str))
{
	_capacity = _size;
	_str = new char[_size + 1];
	strcpy(_str, str);
}

string::string(const string& s)
{
	string tmp(s._str);
	std::swap(_str, tmp._str);
	std::swap(_size, tmp._size);
	std::swap(_capacity, tmp._capacity);

}

string& string::operator=(const string& s)
{
	if (this != &s)
	{
		char* tmp = new char[_capacity + 1];
		strcpy(tmp, s._str);
		delete[] _str;
		_str = tmp;
		_size = s._size;
		_capacity = s._capacity;
	}
	return *this;
}

string::~string()
{
	delete[] _str;
	_str = nullptr;
	_size = _capacity = 0;
}